<?php
/**
 * Created by PhpStorm.
 * User: wxy
 * Date: 2018/11/26
 * Time: 9:37
 */

namespace frontend\modules\common\models;


use Yii;

class BaseHelper
{

    /**
     * @param null $msg
     * @throws \yii\base\ExitException
     */
    public static function Error($msg = null)
    {

        if (is_array($msg))
            Yii::$app->end(json_encode(['status' => $msg[0], 'msg' => $msg[1]], 256));
        Yii::$app->end(json_encode(['status' => 0, 'msg' => $msg], 256));

    }

    /**
     * @param array $data_to_merge
     * @throws \yii\base\ExitException
     */
    public static function Success($data_to_merge = [])
    {
        $data = ['status' => 200];
        $data = array_merge($data, $data_to_merge);
        Yii::$app->end(json_encode($data, 256));
    }
}